package org.lyp.action;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.lyp.dao.UserDao;
import org.lyp.service.UserService;
import org.lyp.vo.User;

import com.opensymphony.xwork2.ActionSupport;


@Namespace("/post")
@Action(value = "loginAction", results = {
		@Result(name = "loginSuccess", location = "/loginSuss.jsp"),
		@Result(name = "loginFailer", location = "/loginFailer.jsp") })
public class LoginAction extends ActionSupport {
	private static final long serialVersionUID = -2266695172069461659L;
	@Resource(name="userService")
	private UserService userService;
	private User user;
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String execute(){
		boolean flag = userService.isExitByNameAndPass(user);
		if(flag){
			System.out.println("suss");
			return "loginSuccess";
		}
		System.out.println("fail");
		return "loginFailer";
	}
}
